package sql

import (
	"context"
	"server/framework/orm/session/model"
)

type Query struct {
	SQL  string
	DB   string // shardingDB 分库分表需要使用 db1.user2
	Args []interface{}
}

type QueryContext struct {
	Type    string // 声明SQL语句类型：insert、select
	Builder QueryBuilder
	Model   *model.Model
}

type QueryResult struct {
	Res any
	Err error
}

type QueryBuilder interface {
	Build() ([]*Query, error)
}

type Executor[T any] interface {
	Exec(ctx context.Context) *QueryResult
}

// Querior QueryResult中可以只是用err, 值从传入的vals、val中获取。使用QueryResult原因：为了添加Handler好统一配置middleware
type Querior[T any] interface {
	Get(ctx context.Context, val interface{}) *QueryResult
	GetMutli(ctx context.Context, vals interface{}) *QueryResult
}

type UseAlias struct {
	Build bool
	Use   bool
}
